<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/views/head.jsp"/>
    <script type="text/javascript">
        $(function () {

            $("#sortHead").headSort();
        });

        function confirmDelete() {
            return confirm("<s:message code='confirmDelete'/>");
        }

        function optSingle(opt) {
            if (Cms.checkeds("ids") == 0) {
                alert("<s:message code='pleaseSelectRecord'/>");
                return false;
            }
            if (Cms.checkeds("ids") > 1) {
                alert("<s:message code='pleaseSelectOne'/>");
                return false;
            }
            var id = $("input[name='ids']:checkbox:checked").val();
            location.href = $(opt + id).attr("href");
        }

        function optDelete(form) {
            if (Cms.checkeds("ids") == 0) {
                alert("<s:message code='pleaseSelectRecord'/>");
                return false;
            }
            if (!confirmDelete()) {
                return false;
            }
            form.action = 'delete.do';
            form.submit();
            return true;
        }

        function jpushNodeInfoView(queryNodeId,title) {
            var data = {};
            data.queryNodeId = queryNodeId;
            data.title = title;
            var obj = ajaxView("/cmscp/core/livenode/jpushLiveBroad.do", "json", data);
            alert("推送：" + obj.msg);
        }

        function ajaxView(mothe, datatype, data) {
            var obj;
            var strurl = window.location.host;
            $.ajax({
                type: "POST",
                url: "http://" + strurl + mothe,
                dataType: datatype,
                data: data,
                async: false,
                success: function (msg) {
                    obj = msg;
                },
                error: function (msg) {
                }
            });
            return obj;
        }
    </script>
</head>
<body class="skin-blue content-body" id="load">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
    <h1>直播 - <s:message code="list"/>
        <small>(<s:message code="totalElements" arguments="${pagedList.totalElements}"/>)</small>
    </h1>
</div>
<div class="content">
    <div class="box box-primary">
        <div class="box-body table-responsive">
            <form class="form-inline ls-search" action="livelist.do" method="get">
                <div class="form-group">
                    <label>直播标题</label>
                    <f:text class="form-control input-sm" name="search_CONTAIN_refLive.title"
                            value="${requestScope['search_CONTAIN_refLive.title'][0]}" style="width:180px;"/>
                </div>
                <%--<div class="form-group">--%>
                <%--<label>开播时间</label>--%>
                <%--<f:text class="form-control input-sm" name="search_GTE_creationDate_Date" value="${search_GTE_creationDate_Date[0]}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});"  style="width:120px;"/>--%>
                <%--</div>--%>
                <%--<div class="form-group">--%>
                <%--<label><s:message code="endTime"/></label>--%>
                <%--<f:text class="form-control input-sm" name="search_LTE_creationDate_Date" value="${search_LTE_creationDate_Date[0]}" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});"  style="width:120px;"/>--%>
                <%--</div>--%>
                <%--<div class="form-group">--%>
                <%--<label>状态</label>--%>
                <%--<select class="form-control input-sm" input-sm name="search_EQ_category.id">--%>
                <%--<option value=""><s:message code="allSelect"/></option>--%>
                <%--<f:options items="${bean.status}" itemValue="id" itemLabel="status" selected="${bean.status['search_EQ_category.id'][0]}"/>--%>
                <%--</select>--%>
                <%--</div>--%>
                <%--<div class="form-group">--%>
                <%--<label><s:message code="special.recommend"/></label>--%>
                <%--<select class="form-control input-sm" name="search_EQ_recommend_Boolean">--%>
                <%--<option value=""><s:message code="allSelect"/></option>--%>
                <%--<f:option value="true" selected="${search_EQ_recommend_Boolean[0]}"><s:message code="yes"/></f:option>--%>
                <%--<f:option value="false" selected="${search_EQ_recommend_Boolean[0]}"><s:message code="no"/></f:option>--%>
                <%--</select>--%>
                <%--</div>--%>
                <f:hidden name="queryNodeId" value="${queryNodeId}"/>
                <button class="btn btn-default btn-sm" type="submit"><s:message code="search"/></button>
            </form>
            <form action="batch_update.do" method="post">
                <tags:search_params/>
                <div class="btn-toolbar ls-btn-bar">
                    <div class="btn-group">
                        <shiro:hasPermission name="core:chooselive:chooselivelist">
                            <button class="btn btn-default" type="button"
                                    onclick="location.href='chooselivelist.do?queryNodeId=${queryNodeId}';">添加
                            </button>
                        </shiro:hasPermission>
                    </div>
                    <div class="btn-group">
                        <shiro:hasPermission name="core:sinatv:generationLive">

                        <button class="btn btn-default" type="button"
                                onclick="$('#load').showLoading();location.href='generationLive.do?returnUrl=livelist&queryNodeId=${queryNodeId}';">
                            生成
                        </button>
                        </shiro:hasPermission>
                    </div>
                    <%--<div class="btn-group">--%>
                    <%--<shiro:hasPermission name="core:special:copy">--%>
                    <%--<button class="btn btn-default" type="button" onclick="return optSingle('#copy_opt_');"><s:message code="copy"/></button>--%>
                    <%--</shiro:hasPermission>--%>
                    <%--<shiro:hasPermission name="core:special:edit">--%>
                    <%--<button class="btn btn-default" type="button" onclick="return optSingle('#edit_opt_');"><s:message code="edit"/></button>--%>
                    <%--</shiro:hasPermission>--%>
                    <%--</div>--%>
                    <%--<div class="btn-group">--%>
                    <%--<shiro:hasPermission name="core:special:delete">--%>
                    <%--<button class="btn btn-default" type="button" onclick="return optDelete(this.form);"><s:message code="delete"/></button>--%>
                    <%--</shiro:hasPermission>--%>
                    <%--</div>--%>
                </div>
                <%------------------------------ [ 推送弹窗 ] -------------------------------%>
                <div id="dialog-message" title="推送信息" style="display: none">
                    <p>标题</p>
                    <%--<input type="text" id="sendViewTitle" value="">--%>
                    <textarea  id="sendViewTitle" value="" rows="5" cols="30"></textarea>
                </div>
                <%--<input type="button" value="Show Dialog" onclick="showDialog();" />--%>
                <script>
                    function showDialog( queryNodeId,title) {
                        $("#dialog-message").dialog({
                            height: 300,
                            width: 400,
                            // 模态开启
                            modal: true,
                            // 是否可拖拽
                            draggable: false,
                            // 最小宽度
                            minWidth: 300,
                            buttons: {
                                "推送信息": function() {
                                    var value =  $("#sendViewTitle").val();
                                    jpushNodeInfoView(queryNodeId,value);
                                    $(this).dialog("close");
                                },
                                "取消": function() {

                                    $(this).dialog("close");
                                }
                            }
                        });
                      $("#sendViewTitle").val(title);
                    }

                </script>

                <table id="pagedTable" class="table table-condensed table-bordered table-hover ls-tb">
                    <thead id="sortHead" pagesort="<c:out value='${page_sort[0]}' />" pagedir="${page_sort_dir[0]}"
                           pageurl="list.do?page_sort={0}&page_sort_dir={1}&${searchstringnosort}">
                    <tr class="ls_table_th">
                        <th width="25"><input type="checkbox" onclick="Cms.check('ids',this.checked);"/></th>
                        <th width="240"><s:message code="operate"/></th>
                        <th width="30" class="ls-th-sort"><span class="ls-sort" pagesort="id">直播ID</span></th>
                        <th class="ls-th-sort"><span class="ls-sort">直播标题</span></th>
                        <th class="ls-th-sort"><span class="ls-sort">发布人</span></th>
                        <th class="ls-th-sort"><span class="ls-sort">来源</span></th>
                        <%--<th class="ls-th-sort"><span class="ls-sort">直播间</span></th>--%>
                        <th class="ls-th-sort"><span class="ls-sort">开播时间</span></th>
                        <th class="ls-th-sort"><span class="ls-sort">状态</span></th>
                        <th class="ls-th-sort"><span class="ls-sort">预约人数</span></th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="bean" varStatus="status" items="${pagedList.content}">
                        <tr>
                            <td><input type="checkbox" name="ids" value="${bean.id}"/></td>
                            <td align="center">
                                    <%--<shiro:hasPermission name="core:special:copy">--%>
                                    <%--<a id="copy_opt_${bean.id}" href="create.do?id=${bean.id}&${searchstring}" class="ls-opt"><s:message code="copy"/></a>--%>
                                    <%--</shiro:hasPermission>--%>
                                    <%--<shiro:hasPermission name="core:livebroadcast:edit">--%>
                                    <%--<a id="edit_opt_${bean.id}" href="edit.do?id=${bean.id}&position=${pagedList.number*pagedList.size+status.index}&${searchstring}" class="ls-opt"><s:message code="edit"/></a>--%>
                                    <%--</shiro:hasPermission>--%>
                                    <%--<shiro:hasPermission name="core:info:list">--%>
                                    <%--<c:url var="infoListUrl" value="../info/list.do">--%>
                                    <%--<c:param name="search_CONTAIN_JinfoSpecials.Jspecial.title" value="${bean.title}"/>--%>
                                    <%--</c:url>--%>
                                    <%--<a id="infoList_opt_${bean.id}" href="${infoListUrl}" class="ls-opt"><s:message code="special.infoList"/></a>--%>
                                    <%--</shiro:hasPermission>--%>
                                <shiro:hasPermission name="ext:livenode:jpushLiveBroad">

                                    <c:choose>
                                        <c:when test="${bean.refLive != null && bean.refLive.status != 0}">
                                            <a href='javascript:void(0)' onclick=" showDialog(${bean.id},'${bean.refLive.title}')"
                                              >推送</a>
                                        </c:when>
                                        <c:otherwise>
                                            <a href='javascript:void(0)' style="background:cyan;color: #0A0A0A" class="ls-opt">推送</a>
                                        </c:otherwise>
                                    </c:choose>
                                </shiro:hasPermission>


                                <shiro:hasPermission name="core:liveref:liverefdelete">
                                    <a href="liverefdelete.do?ids=${bean.id}&queryNodeId=${queryNodeId}"
                                       onclick="return confirmDelete();" class="ls-opt"><s:message code="delete"/></a>
                                </shiro:hasPermission>
                                    <%--<shiro:hasPermission name="core:site:delete">--%>
                                    <%--<c:choose>--%>
                                    <%--<c:when test="${bean.id==1}">--%>
                                    <%--<a class="ls-opt-disabled"><s:message code="recycle"/></a>--%>
                                    <%--</c:when>--%>
                                    <%--<c:otherwise>--%>
                                    <%--<a href="updateDelStatus.do?ids=${bean.id}&${searchstring}" onclick="return confirmDelete();" class="ls-opt"><s:message code="recycle"/></a>--%>
                                    <%--</c:otherwise>--%>
                                    <%--</c:choose>--%>
                                    <%--</shiro:hasPermission>--%>
                            </td>
                            <td align="center"><c:out value="${bean.refLive.id}"/></td>
                            <td align="center"><c:out value="${bean.refLive.title}"/></td>
                            <td align="center"><c:out value=""/>${bean.refLive.compere}</td>
                            <td align="center"><c:if test="${bean.refLive.status eq 0}"><c:out
                                    value="${bean.refLive.source}"/></c:if></td>
                                <%--<td align="center">--%>
                                <%--<c:if test="${bean.refLive.status!=0}"><c:out value="${bean.refLive.source}"/>--%>
                                <%--<a onclick="window.location.href='/cmscp/core/live_broadcast_room/list.do?id=${bean.refLive.id}'"><c:if test="${bean.refLive.status eq 1}">进入直播间</c:if><c:if test="${bean.refLive.status eq 2}">进入直播间</c:if></a>--%>
                                <%--</c:if>--%>
                                <%--</td>--%>
                            <td align="center"><c:out value="${bean.refLive.time}"/></td>
                                <%--<td><c:choose><c:when test="${bean.status}"></c:when><c:otherwise></c:otherwise></c:choose></td>--%>

                            <td align="center">
                                <c:if test="${bean.refLive.status eq 0}">直播预约</c:if>
                                <c:if test="${bean.refLive.status eq 1}">正在直播</c:if>
                                <c:if test="${bean.refLive.status eq 2}">直播回看</c:if>
                            </td>
                            <td align="center"><c:out value=""/></td>
                                <%--<td align="center"><fmt:formatDate value=""/></td>--%>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <c:if test="${fn:length(pagedList.content) le 0}">
                    <div class="ls-norecord"><s:message code="recordNotFound"/></div>
                </c:if>
            </form>
            <form action="livelist.do" method="get" class="ls-page">
                <f:hidden name="queryNodeId" value="${queryNodeId}"/>
                <tags:search_params excludePage="true"/>
                <tags:pagination pagedList="${pagedList}"/>
            </form>
        </div>
    </div>
</div>


</body>
</html>